<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\farmerhouse\FarmerhouseHouse */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Farmerhouse Houses', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="farmerhouse-house-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'template' => '<tr><th style="width:20%">{label}</th><td>{value}</td></tr>',
                        'attributes' => [
                            'id',
                            [
                                'label' => '业务人',
                                'attribute'=>'person.name',
                            ],
                            'name',
                            'farmer.name',
                            'envdesc',
                            'accommodation',
                            'roomnum',
                            'canfeed',
                            'caninnum',
                            'price',
                            [
                                'attribute'=>'envphoto',
                                'format'=>'raw',
                                'value'=>function($model){
                                    $html = '';
                                    $ps = \common\components\Upload::checkGetUrl($model->envphoto,true,'envphoto');
                                    foreach ($ps as $key => $row){
                                        $html .= yii\helpers\Html::img(\common\components\Upload::checkGetUrl($row),['alt' => '缩略图','width' => 100 ,'height' => 100,'style'=>'margin:10px;']);
                                    }
                                    return $html;
                                }
                            ],
                            [
                                'attribute'=>'accommodationphoto',
                                'format'=>'raw',
                                'value'=>function($model){
                                    $html = '';
                                    $ps = \common\components\Upload::checkGetUrl($model->accommodationphoto,true,'accommodationphoto');
                                    foreach ($ps as $key => $row){
                                        $html .= yii\helpers\Html::img(\common\components\Upload::checkGetUrl($row),['alt' => '缩略图','width' => 100 ,'height' => 100,'style'=>'margin:10px;']);
                                    }
                                    return $html;
                                }
                            ],
                            [
                                'attribute'=>'createtime',
                                'format'=>'raw',
                                'value'=>function($model){
                                   return date('Y-m-d H:i:s',$model->createtime);
                                }
                            ],
                            [
                                'attribute'=>'detail',
                                'format'=>'raw',
                                'options'=>['style'=>'width:20%']
                            ],
                            [
                                'attribute'=>'feedlive',
                                'format'=>'raw',
                            ],
                            [
                                'attribute'=>'isrecommand',
                                'format'=>'raw',
                                'value'=>function($model){
                                    return \common\models\farmerhouse\FarmerhouseHouse::$isrecommand[$model->isrecommand];
                                }
                            ],
                            [
                                'attribute'=>'status',
                                'format'=>'raw',
                                'value'=>function($model){
                                    return \common\models\farmerhouse\FarmerhouseHouse::$statues[$model->status];
                                }
                            ],
                            [
                                'attribute'=>'city',
                                'value'=>function($model){
                                    return $model->acity?$model->acity->name:'';
                                }
                            ],
                            [
                                'attribute'=>'county',
                                'value'=>function($model){
                                    return $model->acounty?$model->acounty->name:'';
                                }
                            ],
                            [
                                'attribute'=>'town',
                                'value'=>function($model){
                                    return $model->atown?$model->atown->name:'';
                                }
                            ],
                            'address',
                        ],
                    ]) ?>

                </div>
            </div>
        </div>
    </section>
</section>